package view;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

import model.MeetingInfo;

/**
 * 
 * This is a Class to represent JTable to display the Email(s)
 *
 */
public class MeetingDetailsTable extends JTable implements MouseListener
{
    
    private static final long serialVersionUID = 1393657622996074905L;
    
    private MailDisplayArea mailDisplayArea;
    
   /**
    * Constructor for class MailTable that will display the mail display area used.
    *  
    * @param mailDisplayArea the mail display area reference
    * @param model the model reference
    */
    public MeetingDetailsTable(MailDisplayArea mailDisplayArea, AbstractTableModel model)
    {
        super(model);
        this.mailDisplayArea = mailDisplayArea;
        this.addMouseListener(this);
    }   
    
  /*
   * (non-Javadoc)
   * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
   */
    public void mouseClicked(MouseEvent e)
    {
        if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) 
        {
            JTable target = (JTable)e.getSource();
            int row = target.getSelectedRow();
            
          MeetingInfo meeting = ((MeetingModel)this.getModel()).getEmailAssociatedToRow(row);
          this.mailDisplayArea.displaySelectedMeetingDetail(meeting);
        }
    }

    
    public void mousePressed(MouseEvent e)
    {
        
    }

    
    public void mouseReleased(MouseEvent e)
    {
        
    }

    
    public void mouseEntered(MouseEvent e)
    {
        
    }

    
    public void mouseExited(MouseEvent e)
    {
        
    }
}
